package com.eveinfo.display.planner;

import android.content.Context;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;

import com.eveinfo.display.LayoutUtils;
import com.eveinfo.tools.Tools;

public class PlannerRenderer extends TableLayout {
	
	private Context context;
	private TextView plannerName;
	private TextView time;
	
	public PlannerRenderer(Context context) {
		super(context);
		this.context = context;
		createUI();
	}

	private void createUI() {
		TableRow rowTop = new TableRow(context);
		rowTop.setPadding(0, 5, 0, 5);
		LayoutUtils.Layout.WidthFill_HeightWrap.applyTableLayoutParams(rowTop);

		plannerName = new TextView(context);
		plannerName.setTextSize(20);
		LayoutUtils.Layout.WidthWrap_HeightWrap.applyTableRowParams(plannerName);
		rowTop.addView(plannerName);


		TableRow rowBottom = new TableRow(context);
		rowBottom.setPadding(0, 0, 0, 0);
		LayoutUtils.Layout.WidthFill_HeightWrap.applyTableLayoutParams(rowBottom);

		time = new TextView(context);
		time.setPadding(15, 0, 0, 0);
		time.setTextSize(12);
		LayoutUtils.Layout.WidthWrap_HeightWrap.applyTableRowParams(time);
		rowBottom.addView(time);
		
		addView(rowTop);
		addView(rowBottom);
	}

	public void setPlanner(Planner planner) {
		plannerName.setText(planner.getName());
		time.setText(planner.getSize()+" Skills - "+Tools.convertMinutesToTime(planner.getTime()));
	}

}
